//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package objects;

import common.GlobalID;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;

public class FactoryEntry {
    private final String name;
    private final int slots;
    private final int id;
    private final int unlockLevel;
    private final int timeSec;
    private final int timeMin;
    private final int ExpToBuild;
    private final LinkedHashMap<Integer, ProductionsGoodEntry> goodsById = new LinkedHashMap();
    private final LinkedHashMap<String, ProductionsGoodEntry> goodsByName = new LinkedHashMap();

    public FactoryEntry(String name, int slots, int unlockLevel, int id, int timeMin, int timeSec, int ExpToBuild) {
        this.name = name;
        this.slots = slots;
        this.id = id;
        this.unlockLevel = unlockLevel;
        this.timeMin = timeMin;
        this.timeSec = timeSec;
        this.ExpToBuild = ExpToBuild;
    }

    public String getName() {
        return this.name;
    }

    public int getSlots() {
        return this.slots;
    }

    public int getId() {
        return this.id;
    }

    public int getUnlockLevel() {
        return this.unlockLevel;
    }

    public int getConstructionTime() {
        return this.timeMin * 60 + this.timeSec;
    }

    public int getExpToBuild() {
        return this.ExpToBuild;
    }

    public void addGoodEntryWithObjectClass(ProductionsGoodEntry sge, int objectClass) {
        if(sge.getName() != null) {
            sge.setInstance(this.goodsById.size());
            this.goodsByName.put(sge.getName(), sge);
            this.goodsById.put(sge.getGlobalID(Integer.valueOf(objectClass)), sge);
        } else {
            int lastEntryInstance = this.goodsById.size() - 1;
            ProductionsGoodEntry last = (ProductionsGoodEntry)this.goodsById.get(Integer.valueOf(GlobalID.create(objectClass, lastEntryInstance)));
            LinkedHashMap newReqirements = sge.getRequirements();
            Iterator var7 = newReqirements.keySet().iterator();

            while(var7.hasNext()) {
                String reqName = (String)var7.next();
                last.addRequirement(reqName, (Integer)newReqirements.get(reqName));
            }
        }

    }

    public ProductionsGoodEntry getGoodById(Integer id) {
        return (ProductionsGoodEntry)this.goodsById.get(id);
    }

    public ProductionsGoodEntry getGoodByName(String name) {
        return (ProductionsGoodEntry)this.goodsByName.get(name);
    }

    public Collection<ProductionsGoodEntry> getGoods() {
        return this.goodsById.values();
    }

    public String toString() {
        return this.name + ": [Slots:" + this.slots + ", UnlockLevel:" + this.unlockLevel + ", id:" + this.id + "]";
    }
}
